import './box.js'
export const MessageBox = {
  confirm: (text) => {
    return new Promise((resolve, reject) => {
      const app = new Vue({
        data: {
          text,
          showBox: true
        },

        template: `
          <box @cancel="handleCancel" @ok="handleOk" v-if="showBox">
            {{text}}
          </box>
        `,

        methods: {
          handleCancel() {
            this.showBox = false
            reject()
          },
          handleOk() {
            this.showBox = false
            resolve()
          }
        },
      })
      const container = document.createElement('div')
      document.body.appendChild(container)
      app.$mount(container)
    })
  }
}